/*
 * XML Type:  RelationCollectionType
 * Namespace: http://www.data-archive.ac.uk/dext/schema/draft
 * Java type: uk.da.dext.RelationCollectionType
 *
 * Automatically generated - do not modify.
 */
package uk.da.dext.impl;

import uk.da.dext.ObjectRelationType;

/**
 * An XML RelationCollectionType(@http://www.data-archive.ac.uk/dext/schema/draft).
 *
 * This is a complex type.
 */
public class RelationCollectionTypeImpl extends org.apache.xmlbeans.impl.values.XmlComplexContentImpl implements uk.da.dext.RelationCollectionType
{
    private static final long serialVersionUID = 1L;
    
    public RelationCollectionTypeImpl(org.apache.xmlbeans.SchemaType sType)
    {
        super(sType);
    }
    
    private static final javax.xml.namespace.QName OBJECTRELATION$0 = 
        new javax.xml.namespace.QName("http://www.data-archive.ac.uk/dext/schema/draft", "objectRelation");
    private static final javax.xml.namespace.QName ID$2 = 
        new javax.xml.namespace.QName("", "id");
    
    
    /**
     * Gets array of all "objectRelation" elements
     */
    public uk.da.dext.ObjectRelationType[] getObjectRelationArray()
    {
        synchronized (monitor())
        {
            check_orphaned();
            java.util.List<ObjectRelationType> targetList = new java.util.ArrayList<ObjectRelationType>();
            get_store().find_all_element_users(OBJECTRELATION$0, targetList);
            uk.da.dext.ObjectRelationType[] result = new uk.da.dext.ObjectRelationType[targetList.size()];
            targetList.toArray(result);
            return result;
        }
    }
    
    /**
     * Gets ith "objectRelation" element
     */
    public uk.da.dext.ObjectRelationType getObjectRelationArray(int i)
    {
        synchronized (monitor())
        {
            check_orphaned();
            uk.da.dext.ObjectRelationType target = null;
            target = (uk.da.dext.ObjectRelationType)get_store().find_element_user(OBJECTRELATION$0, i);
            if (target == null)
            {
                throw new IndexOutOfBoundsException();
            }
            return target;
        }
    }
    
    /**
     * Returns number of "objectRelation" element
     */
    public int sizeOfObjectRelationArray()
    {
        synchronized (monitor())
        {
            check_orphaned();
            return get_store().count_elements(OBJECTRELATION$0);
        }
    }
    
    /**
     * Sets array of all "objectRelation" element
     */
    public void setObjectRelationArray(uk.da.dext.ObjectRelationType[] objectRelationArray)
    {
        synchronized (monitor())
        {
            check_orphaned();
            arraySetterHelper(objectRelationArray, OBJECTRELATION$0);
        }
    }
    
    /**
     * Sets ith "objectRelation" element
     */
    public void setObjectRelationArray(int i, uk.da.dext.ObjectRelationType objectRelation)
    {
        synchronized (monitor())
        {
            check_orphaned();
            uk.da.dext.ObjectRelationType target = null;
            target = (uk.da.dext.ObjectRelationType)get_store().find_element_user(OBJECTRELATION$0, i);
            if (target == null)
            {
                throw new IndexOutOfBoundsException();
            }
            target.set(objectRelation);
        }
    }
    
    /**
     * Inserts and returns a new empty value (as xml) as the ith "objectRelation" element
     */
    public uk.da.dext.ObjectRelationType insertNewObjectRelation(int i)
    {
        synchronized (monitor())
        {
            check_orphaned();
            uk.da.dext.ObjectRelationType target = null;
            target = (uk.da.dext.ObjectRelationType)get_store().insert_element_user(OBJECTRELATION$0, i);
            return target;
        }
    }
    
    /**
     * Appends and returns a new empty value (as xml) as the last "objectRelation" element
     */
    public uk.da.dext.ObjectRelationType addNewObjectRelation()
    {
        synchronized (monitor())
        {
            check_orphaned();
            uk.da.dext.ObjectRelationType target = null;
            target = (uk.da.dext.ObjectRelationType)get_store().add_element_user(OBJECTRELATION$0);
            return target;
        }
    }
    
    /**
     * Removes the ith "objectRelation" element
     */
    public void removeObjectRelation(int i)
    {
        synchronized (monitor())
        {
            check_orphaned();
            get_store().remove_element(OBJECTRELATION$0, i);
        }
    }
    
    /**
     * Gets the "id" attribute
     */
    public java.lang.String getId()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(ID$2);
            if (target == null)
            {
                return null;
            }
            return target.getStringValue();
        }
    }
    
    /**
     * Gets (as xml) the "id" attribute
     */
    public org.apache.xmlbeans.XmlID xgetId()
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.XmlID target = null;
            target = (org.apache.xmlbeans.XmlID)get_store().find_attribute_user(ID$2);
            return target;
        }
    }
    
    /**
     * Sets the "id" attribute
     */
    public void setId(java.lang.String id)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.SimpleValue target = null;
            target = (org.apache.xmlbeans.SimpleValue)get_store().find_attribute_user(ID$2);
            if (target == null)
            {
                target = (org.apache.xmlbeans.SimpleValue)get_store().add_attribute_user(ID$2);
            }
            target.setStringValue(id);
        }
    }
    
    /**
     * Sets (as xml) the "id" attribute
     */
    public void xsetId(org.apache.xmlbeans.XmlID id)
    {
        synchronized (monitor())
        {
            check_orphaned();
            org.apache.xmlbeans.XmlID target = null;
            target = (org.apache.xmlbeans.XmlID)get_store().find_attribute_user(ID$2);
            if (target == null)
            {
                target = (org.apache.xmlbeans.XmlID)get_store().add_attribute_user(ID$2);
            }
            target.set(id);
        }
    }
}
